package com.qdu.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;

import com.qdu.entity.Hr;


public interface HrMapper {


	
	@Select("select * from hr where hid=#{hid}")
	Hr getOnehr(String hid);

	//通过hr获得简历列表
	@Select("select j.jobname,r.rfid,r.img,r.uid,r.statu from job j,hr h,resumefile r "
			+ "where j.jid = r.jid and (h.bid = j.bid and h.batchid = j.batchid) and h.hid = #{hid}")
	List<Map<String,Object>> getresumeListByhr(String hid);
	//建立状态默认为0
	// 建立建立状态为正在审核statu=1
	@Update("update resumefile set statu=1 where rfid=#{rfid}")
	@Transactional
	int alterResumeStatuToIng(int rfid);
	// 修改简历状态为通过statu=2 
	@Update("update resumefile set statu=2 where rfid=#{rfid}")
	@Transactional
	int alterResumeStatuToPass(int rfid);
	//修改简历状态为审核不通过statu=3
	@Update("update resumefile set statu=3 where rfid=#{rfid} and hid=1")
	@Transactional
	int alterResumeStatuNotPass(int rfid);
	
	//l-addHr
	@Transactional
	@Insert("insert into hr(hid,hemail,hpwd,hgender,hphone,hjobname,himg,bid,batchid) "
			+ "values(#{hid},#{hemail},#{hpwd},#{hgender},#{hphone},#{hjobname},#{himg},#{bid},#{batchid})")
	int addHr(Map<String,Object> h);
	
	@Transactional
	@Insert("insert into roles values(3,#{hid},'hr',#{hpwd})")
	int addrole(@RequestParam("hid")String hid,@RequestParam("hpwd")String hpwd);
	
	  @Update("UPDATE hr SET hpwd = #{hpwd} WHERE hid = #{hid}")
	    int update(@Param("hpwd") String hpwd,@Param("hid") String hid);
	  
	  @Update("UPDATE roles SET rpassword = #{hpwd} WHERE rolename = #{hid}")
	    int updaterole(@Param("hpwd") String hpwd,@Param("hid") String hid);

}
